package vn.allmobile.ambnews.activities.main;


import vn.allmobile.ambnews.AboutActivity;
import vn.allmobile.ambnews.BaseActivity;
import vn.allmobile.ambnews.R;
import vn.allmobile.ambnews.SettingsActivity;
import vn.allmobile.ambnews.customview.FlipViewInterface;
import vn.allmobile.ambnews.flipview.FlipView;
import vn.allmobile.ambnews.flipview.OverFlipMode;
import vn.allmobile.ambnews.network.NetworkAPI;
import vn.allmobile.ambnews.utils.Log;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.aphidmobile.flip.FlipViewController;

public class MainActivity extends BaseActivity  {
	//FlipViewController flipview ;
	FlipViewInterface flipview ;
	//FlipView flipview ;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		try{
			flipview = (FlipView)findViewById(R.id.flipViewMain);
			flipview.setOverFlipMode(OverFlipMode.RUBBER_BAND);	
		}catch(Exception e){
			flipview = (FlipViewController)findViewById(R.id.flipViewMain);
		}
		

		MainFlipViewAdapter adapter = new MainFlipViewAdapter(NetworkAPI._papers,this);
		adapter._flipview = flipview;
		flipview.setAdapter(adapter);
			
				
	}

	public void onRefresh(View v){}
	public void onBackClick(View v){
		onBackPressed();
		//overridePendingTransition(R.anim.grow_from_bottom,R.anim.slide_out_right);
	}
	
	public void onSettingClick(View v)
	{
		Intent mIntent = new Intent(this, SettingsActivity.class);			
		startActivity(mIntent);
	}
	
	public void onMoreClick(View v)
	{
		Intent mIntent = new Intent(this, MainAllPapersActivity.class);			
		startActivity(mIntent);	
	}
	
	/*@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getSupportMenuInflater().inflate(R.menu.main,  menu);
		return super.onCreateOptionsMenu(menu);
		
	}


	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
			case R.id.menu_settings:
			 Intent mIntent_setting = new Intent(getApplicationContext(), SettingsActivity.class);			
			 startActivity(mIntent_setting);
			return true;
			case R.id.menu_paper_manage:
				 Intent mIntent = new Intent(getApplicationContext(), MainAllPapersActivity.class);			
				 startActivity(mIntent);
				return true;
			case R.id.menu_exits:
				android.os.Process.killProcess(android.os.Process.myPid());
				return true;
			case R.id.menu_about:
				 Intent intent = new Intent(getApplicationContext(), AboutActivity.class);			
				 startActivity(intent);
			default :
				return super.onMenuItemSelected(featureId, item);
		}
		
	}
*/
	/* (non-Javadoc)
	 * @see android.app.Activity#onBackPressed()
	 */
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		Log.v("Back pressed");
		super.onBackPressed();	    
	    finish();
	}
	
	@Override
	  protected void onResume() {
	    super.onResume();
	    flipview.onResume();
	  }

	  @Override
	  protected void onPause() {
	    super.onPause();
	    flipview.onPause();
	  }


}
